package com.jy.wms.web;

import com.joyi.gate.comm.SessionInfo;
import com.joyi.gate.safety.vo.UserInfo;
import com.jy.wms.service.SysMenuService;
import net.sf.json.JSON;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * Created by YUJIE on 2018/8/22.
 * 发运订单
 */
@Controller
@RequestMapping("/outOperation")
public class WmsoutOperationShipment {
    @Autowired
    SysMenuService menuService;

    /**
     * 查询列表
     * @param menu
     * @param model
     * @param session
     * @return
     */
    @RequestMapping(value = "shipment/{menu}")
    public String purchase(@PathVariable("menu") String menu, Model model, HttpSession session) {
        model.addAttribute("functions",menuService.getFunctions(menu));
        UserInfo userinfo = (UserInfo) session.getAttribute(SessionInfo.USER_INFO);
        JSONObject userJson = JSONObject.fromObject(userinfo);
        model.addAttribute("UserInfo",userJson.toString());
        return "outOperation/shipment/shipment";
    }

    /**
     * 添加
     * @return
     */
    @RequestMapping(value = "AddShipment")
    public String addshipment() {
        return "outOperation/shipment/addshipment";
    }

    /**
     * ERP提取
     * @return
     */
    @RequestMapping(value = "toERPShipment")
    public String toERPShipment() {
        return "outOperation/shipment/erpShipment";
    }

    /**
     * 编辑
     * @return
     */
    @RequestMapping(value = "EditShipment")
    public String editshipment() {
        return "outOperation/shipment/editshipment";
    }

    // 查看明细
    @RequestMapping(value = "LookDetail")
    public String lookdetail(){return "outOperation/shipment/lookdetail";}

    //修改承运商类别
    @RequestMapping(value = "EditForwardingAgent")
    public String editForwardingAgent(){return "outOperation/shipment/editForwardingaAent";}

    // 查看库存余量
    @RequestMapping(value = "SearchInventory")
    public String searchinventory(){return "outOperation/shipment/searchinventory";}

    // 退单重报
    @RequestMapping(value = "ReturnInventoryAgain")
    public String returnInventoryAgain(){return "outOperation/shipment/returnInventoryAgain";}

    // 查看拆单明细
    @RequestMapping(value = "SeparatedDetail")
    public String SeparatedDetail(){return "outOperation/shipment/searchSeparatedDetail";}

    // 查看拆单行
    @RequestMapping(value = "SeparatedRow")
    public String SeparatedRow(String id, Model model){
        model.addAttribute("id",id);
        return "outOperation/shipment/searchSeparatedRow";
    }

    // 查看分配明细
    @RequestMapping(value = "AllocationDetail")
    public String AllocationDetail(){return "outOperation/shipment/searchAllocationDetail";}

    // 查看分配行
    @RequestMapping(value = "AllocationRow")
    public String AllocationRow(String id, Model model){
        model.addAttribute("id",id);
        return "outOperation/shipment/searchAllocationRow";
    }

    // 查看装箱明细
    @RequestMapping(value = "PackingDetail")
    public String PackingDetail(){return "outOperation/shipment/searchPackingDetail";}

    // 查看装箱明细行
    @RequestMapping(value = "PackingDetailRow")
    public String PackingDetailRow(String id,String xbh, Model model){
        model.addAttribute("id",id);
        model.addAttribute("xbh",xbh);
        return "outOperation/shipment/searchPackingRow";
    }

    // 批量打印快递面单
    @RequestMapping(value = "BatchPrintExpressSingle")
    public String BatchPrintExpressSingle(){
        return "outOperation/shipment/batchPrintExpressSingle";
    }

}
